<?php

/**
 * 
 * @author NutMotion <simonotm.linux@gmail.com> 
 */
/*
 * Creates a new record into database table webpage, with the values received in the 
 * associative array arWebpageData
 * 
 * @param String[] arWebpageData Associative array which must contain 2 entry: 
  'url': url of the page / type:string
  'title': title of the page / type:string
 * 
 * @return ResultContext Return parameter and additional information about the outcome of the operation
 */
require_once(dirname(__FILE__) . "/../commons/common-funcs.php");
require_once(dirname(__FILE__) . "/../db/common-operations.php");

/*
 * Creates a new record in the webpage table, or fetches the id of existing webpage in case of a duplicate
 * @param $arWebpageData String[] Associative array which must contain 2 keys : url and title
 * 
 */
function dbCreateWebPage($arWebpageData) {
    //  function dbCreateWebPage($url,$title) would be clearer, and overwhole better signature ? 
//   Here's how the final query we vant to build here looks like:
//   INSERT INTO webpage (url, title) VALUES ($arWebpageData['url'], $arWebpageData['title']); 
    $queryTable = "webpage";
    $queryFields = "url, title";
    $queryValues="'".mysql_real_escape_string($arWebpageData['url'])."', '".mysql_real_escape_string($arWebpageData['title'])."'";

    connect();
    
    //
    $resultContext=insertIntoTable2($queryTable, $queryFields, $queryValues);
    
    
    
    return $resultContext;  // for the moment, we don't do any error management in this function.
    
}

?>
